# Description

This database has both EEG data and scripts. You should place both 'eeg' and 'scrips' folder in the same folder.

- eeg: contains recorded eeg data
- scripts: contains source code for analysis


# About EEG data
All EEG data are saved with BrainVision Core Data Format. Each recording consists of a `.vhdr`, `.vmrk` and `.eeg` files. All EEG files are anonymized.

## Description of markers

| Marker Number | Stimulus | Description                  |
| ------------- | -------- | ---------------------------- |
| 1             | S1       | Standard stimuli in Stream 1 |
| 2             | D1       | Deviant stimuli in Stream 1  |
| 4             | S2       | Standard stimuli in Stream 2 |
| 8             | D2       | Deviant stimuli in Stream 2  |
| 16            | S3       | Standard stimuli in Stream 3 |
| 32            | D3       | Deviant stimuli in Stream 3  |
| 129           | S1       | S1 just after the D1         |
| 132           | S2       | S2 just after the D2         |
| 144           | S3       | S3 just after the D3         |

Markers 129, 132 and 144 are for excluding the standard stimuli just after the deviant stimuli from analyses.

## EEG files
EEG file names meet BIDS format. All tasks are below.
- low
  - Subjects paid attention to Stream 1
- mid
  - Subjects paid attention to Stream 2
- High
  - Subjects paid attention to Stream 3

# About scripts

In a scrips folder, script for Matlab and Python are contained. The files which has extension of '.m' are for Matlab and '.py' are for Python.

# Dependencies for Matlab

To run analyses, you need to clone two git repository into 'scripts/libs'

- bvaloader: for loading brain vision EEG file
  - <https://github.com/stefanSchinkel/bvaloader.git>
- eeglab: for plotting topography map
  - <https://github.com/sccn/eeglab.git>

# Dependencies for Python

- Python3
- numpy
- scipy
- scikit-learn
- pandas
- matplotlib
- seaborn
- mne
- pyriemann

# How To Run

## Matlab

Please run "run_erp_analysis.m" script. All figures will be saved in the "results" folder. You will find the ERP plots for each subject, grand averaged ERP plos and scalp topography of grand averaged ERP plots.

### Name Conventions

#### ERP plots for each subject

```
sub-<subject_name>_responses_to_<stream_number>.png
```

#### grand averaged ERP plots

```
grand_responses_to_<stream_number>.png
```

#### scalp topography

```
grand_topo_responses_to_<stream_number>_<time>.png
``````

## Python

Please run "run_classification.py" to run classification. The results of the classification will be saved with json format in the "results" folder. If you like to plot other plots and tables, please run scripts below.

- confusion_matrix.py
  - to plot grand averaged confusion matrices
- plot_classification_scores.py
  - to plot barplot of the classification scores
- classification_scores_table.py
  - to print the table shows classification scores